package com.yn.pet.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum NoticeTypeEnum {

    ANNOUNCEMENT(1, "通知"),
    NOTICE(2, "公告"),
    FUNCTION_INTRODUCTION(3, "功能介绍"),
    COMMON_PROBLEM(4, "常见问题");

    private final Integer code;
    private final String name;

    public static NoticeTypeEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (NoticeTypeEnum enumObj : NoticeTypeEnum.values()) {
            if (enumObj.getCode().equals(code)) {
                return enumObj;
            }
        }
        return null;
    }
    public static String getNameByCode(Integer code) {
        NoticeTypeEnum noticeTypeEnum = getByCode(code);
        if (noticeTypeEnum == null) {
            return null;
        }
        return noticeTypeEnum.getName();
    }
}